using System;
using System.Collections;
using System.Text;
using System.Xml;
using System.Data;
using InfoJetSoft.Service.Entity;
using InfoJetSoft.Service.Worker;

namespace InfoJetSoft.Service.Util
{
	/// <summary>
	/// Summary description for DBUtil.
	/// </summary>
	public class DBUtil
	{
		public static string buildQuerySQL( string sql, string where )
		{
			int fromIndex = sql.IndexOf( " from " );
			if( fromIndex > 0 )
			{
				int asIndex = sql.IndexOf( " as ", fromIndex );
				int bracketIndex = sql.IndexOf( "}", asIndex );
				string whereSql = "";
				if( bracketIndex > 0 )
				{
					whereSql = sql.Substring( 0, bracketIndex ) + where + sql.Substring( bracketIndex );
				}
				else
				{
					whereSql = sql + where;
				}
				return whereSql;
			}
			return sql;
		}

	}
}
